package com.taotao.enums.apt.anno;


import com.google.auto.service.AutoService;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * {@link AbstractProcessor} 就属于 Pluggable Annotation Processing API
 */
@AutoService(Processor.class)
public class BaseEnumTypeProcessor extends AbstractProcessor {

    @Override
    public Set<String> getSupportedAnnotationTypes() {
        // 与注解 @SupportedAnnotationTypes 等效
        return new HashSet<>(Arrays.asList(BaseEnumType.class.getName()));
    }


    @Override
    public SourceVersion getSupportedSourceVersion() {
        //设置为能够支持最新版本   @SupportedSourceVersion 等效
        return SourceVersion.latestSupported();
    }


    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        for (Element e : roundEnv.getRootElements()) {
            System.out.println(e);
        }
        return false;
    }
}